import React, { Component } from 'react'
import {Route, Switch, Redirect} from 'react-router-dom'

import Header from "./components/Header"
import MyNavLink from "./components/MyNavLink"
import Home from './pages/Home'
import About from './pages/About'

export default class App extends Component {

  render() {
    return (
      <div>
        <div className="row">
          <div className="col-xs-offset-2 col-xs-8">
            <Header/>
          </div>
        </div>

        <div className="row">
          <div className="col-xs-offset-2 col-xs-2">
            <div className="list-group">
              <MyNavLink to="/home">Home</MyNavLink>
              <MyNavLink to="/about">Abort</MyNavLink>
            </div>
          </div>

          <div className="col-xs-6">
            <div className="card">
              <div className="card-body">
                <Switch>
                  <Route path="/home" component={Home}/>
                  <Route path="/about" component={About}/>
                  {/* 所以Route都不匹配的时候走Redirect */}
                  <Redirect to="/home"/>
                </Switch>
              </div>
            </div>
          </div>
        </div>

      </div>
    )
  }
}
